package org.smart.access.controller;

import cn.dev33.satoken.util.SaResult;
import org.smart.access.dto.UserInfo;
import org.smart.access.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/house")
public class HouseController {

    @Autowired
    private HouseService houseService;

    @GetMapping("/owner")
    public SaResult getOwnerName(@RequestParam("building") String building,
                                 @RequestParam("room") String room) {
        UserInfo userInfo = houseService.getOwner(building, room);
        if (null == userInfo) {
            return SaResult.error("未找到房屋");
        }else {
            return SaResult.data(houseService.getOwner(building, room));
        }
    }

}
